// 基础校验处理器（必填项）
package com.zhang.bingmei_incomeexpenditure.service.chain.Impl;

import com.zhang.bingmei_incomeexpenditure.entity.ie.updateNew.UpdateDoubleDTO;
import com.zhang.bingmei_incomeexpenditure.service.chain.ValidationHandler;
import org.apache.commons.lang3.StringUtils;

public class RequiredFieldValidationHandler implements ValidationHandler {
    private ValidationHandler next;

    @Override
    public void setNext(ValidationHandler next) {
        this.next = next;
    }

    @Override
    public void validate(UpdateDoubleDTO dto) {
        // 校验必填项
        if (dto.getId() == null && StringUtils.isBlank(dto.getCode())) {
            throw new RuntimeException("新增数据code不能为空");
        }
        if (dto.getId() == null && StringUtils.isBlank(dto.getYear())) {
            throw new RuntimeException("新增数据year不能为空");
        }
        // 传递给下一个处理器
        if (next != null) {
            next.validate(dto);
        }
    }
}





